/*----------------------------------------\ | Concatenate characters n times; | |------------------------------------------------| |--------------------------------------------------------------------| |--------------------------| | Arguments: | | char - the special characters; | | n - the number of time you want to write the special characters;| |----------------------------| |--------------------------------------------------------------------| |---------------------------------------| | Example: %put %_repeat('-',10); | | Usage: %_repeat(char,n); | \--------------------------------------*/ %macro _repeat(char,n); /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 12-25-2001 1:09pm; | | Purpose: Concatenate characters n times; | \--------------------------------------------*/ %local string char linesize n _ijklmn_; %let char=%sysfunc(dequote(&char)); %let linesize = %SYSFUNC(GETOPTION(linesize)); %let string=; %if (%quote(&n) eq) %then %let n=&linesize.; %else %if %sysfunc(rxmatch(%sysfunc(rxparse(.|$a|$A|$w)),&n)) %then %do; %put ==> Alert! The character "&char" cannot be repeated "&n" times; %goto finish; %end; %if &n lt 0 %then %let n=&linesize.; %else %if &n =0 %then; %else %do; %do _ijklmn_=1 %to &n; %let string=&string.%quote(&char); %end; %end; &string %finish: %mend _repeat;